<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/pendingOrders.do"/>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.sales.Orders,
                 java.util.ArrayList,
                 com.scalar.chiptrack.commons.Constants,
                 com.scalar.chiptrack.commons.Labels"%>
<%@ page import="com.scalar.chiptrack.users.Functionality" %>
<%@ page import="com.scalar.chiptrack.users.User" %>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script  language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/quickSearch.js"></script>
<script language="JavaScript">
    window.onload = init;

    function init()
    {
        qs_1 = new QuickSearch(document.ordersForm['salesOrderId'], document.ordersForm.qs1, false);
        qs_2 = new QuickSearch(document.ordersForm['customerPO'], document.ordersForm.qs2, false);
        qs_3 = new QuickSearch(document.ordersForm['manufacturingPartNo'], document.ordersForm.qs3, false);
        qs_4 = new QuickSearch(document.ordersForm['customerId'], document.ordersForm.qs4, false);
    }
    function openSalesOrder(salesOrderId)
    {
        var isSample = document.ordersForm.isSample.value;
       // newWindow =
			window.open('order.do?action=printOrder&revisedDate=false&salesOrderId='+salesOrderId+'&isSample='+isSample,'pendingOrdersView','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=600,height=600,left=100,top=50,resizable=yes');
  	//newWindow.focus();
    }

    function searchOrderList(theForm)
    {
        if(!isInteger(theForm.year.value)) {
            errors = "<li> Please enter a valid integer";
            var pa=document.getElementById("errors1");
            pa.innerHTML = errors;
            theForm.year.select();
            return false;
        }
        theForm.action.value = "SearchOrder";
        //theForm.submit();
        return true;
    }

    function GetAllProducts()
    {
        newWindow = window.open('loadProducts.do','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=500,height=600,resizable=no');
  	newWindow.moveTo(300,30);
  	newWindow.focus();
    }

    function assignProduct(passedValue)
    {
	document.ordersForm.manufacturingPartNo.value = passedValue;
	window.focus();
    }

    var dateElement = "";
    function openCalendar(dateValue)
    {
	dateElement = dateValue;
  	newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
  	newWindow.moveTo(550,180);
  	newWindow.focus();
    }

    function assignDate(passedValue)
    {
	dateElement.value=passedValue;
	window.focus();
    }

    function showErrorReportPage()
    {
        newWindow = window.open ('<%=chipTracContext%>/reportProblem.do','reportProblem','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=750,height=400,resizable=no');
        newWindow.focus();
    }

function reset()
{
    document.ordersForm.reset();
    qs_1.resetQuickSearchCntrl();
    qs_2.resetQuickSearchCntrl();
    qs_3.resetQuickSearchCntrl();
    qs_4.resetQuickSearchCntrl();
}
</SCRIPT>
</HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
    <TR>
	    <td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
            <!-- Side Navigation start -->
            <%
            String heading = "";
            String isSample = "1";
            %>
            <%
            if((request.getParameter("isSample") != null) && (request.getParameter("isSample").equals("0")))
            {
                heading = "Sample Orders"; isSample="0";
            %>
            <%@ include file="/jsp/sales/sample_order_menu.jsp" %>
            <% } else {
                 heading = "Sales Orders";isSample="1";
            %>
                <%@ include file="/jsp/sales/sales_order_menu.jsp" %>
            <% } %>
            <!-- end of the side navigations -->
        </td>
        <TD bgcolor="#ffffff"><IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
        <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
        <TD valign="top" width="100%">
            <IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
            <!-- from here your body starts -->
            <center><span class="NArialW">Pending <%=heading%></span></center>
            <img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10>
            <html:form name="ordersForm" method="post"  onsubmit="return searchOrderList(document.ordersForm);" action="/pendingOrders" type="com.scalar.chiptrack.sales.forms.OrdersForm">
            <table border="0" width="100%" align=left>
                <tr>
                    <td>
                        <table border="0" width="100%" align=left>
                            <tr>
                                <td colspan="5">
                                    <chiptrack:info styleClass="NArialL" />
                                    <chiptrack:errors styleClass="NArialL" />
                                    <chiptrack:messages type="info" styleClass="NArialL" />
                                </td>
                            </tr>
                            <tr><td colspan="5" align="left" class='NArialL'><FONT id="errors1" color='FF0000'></FONT></TD></TR>
                            <tr>
                              <td width="20%" align="right" class="NArialL">Quick Search:</td>
                              <td width="20%">
                                <input type="text" name="qs3" class="txfield" size='33' onkeyup='quickSearch(qs_3);'/>
                              </td>
                              <td width="5%">&nbsp;</td>
                              <td width="20%" align="right"><font class="NArialL">Quick Search:</font></td>
                              <td width="25%">
                                    <input type="text" name="qs4" class="txfield" size='33' onkeyup='quickSearch(qs_4);'/>
                              </td>
                            </tr>
                            <tr>
                                <td width="20%" align="right">
                                    <font class="NArialL">Product Name:<br>(<bean:message key="label.mfgPartNumber" />)</font>
                                </td>
                                <td width="20%" class="NArialL">
                                    <html:select name="ordersForm" property="manufacturingPartNo" styleClass="txfield">
                                        <html:options collection="productList" property="value" labelProperty="label"/>
                                    </html:select>
                                </td>
                                <td width="5%">&nbsp;</td>
                                <td width="20%" align="right"><font class="NArialL">Customer Name:</font></td>
                                <td width="25%">
                                    <font class="NArialL">
                                    <html:select name="ordersForm"  property="customerId" styleClass="txfield">
                                        <html:options collection="customerList" property="value" labelProperty="label"/>
                                    </html:select>
                                    </font>
                                </td>
                            </tr>
                            <tr>
                                <td align="right"><font class="NArialL">Quick Search:</font></td>
                                <td>
                                    <input type="text" name="qs1" class="txfield" size='20' onkeyup='quickSearch(qs_1);'/>
                                </td>
                                <td>&nbsp;</td>
                                <td align="right"><font class="NArialL">Quick Search:</font></td>
                                <td>
                                    <input type="text" name="qs2" class="txfield" size='20' onkeyup='quickSearch(qs_2);'/>
                                </td>
                            </tr>
                            <tr>
                                <td align="right"><font class="NArialL">Sales Order #:</font></td>
                                <td>
                                    <font class="NArialL">
                                    <html:select name="ordersForm" property="salesOrderId" styleClass="txfield">
                                        <html:options collection="salesOrdersList" property="value" labelProperty="label"/>
                                    </html:select>
                                </td>
                                <td>&nbsp;</td>
                                <td align="right"><font class="NArialL">Customer PO #:</font></td>
                                <td>
                                    <html:select name="ordersForm" property="customerPO" styleClass="txfield">
                                        <html:options collection="posList" property="value" labelProperty="label"/>
                                    </html:select>
                                </td>
                            </tr>
                            <tr>
                                  <td align="right" class="NArialL"><bean:message key="label.sales.endCustomer"/>:</td>
                                  <td class="NArialL">
                                <html:select name="ordersForm" property="endCustomer" styleClass="txfield">
                                    <html:option value="0">All <bean:message key="label.sales.endCustomer"/>s</html:option>
                                    <html:options collection="endCustomerList" property="value" labelProperty="label"/>
                                </html:select></td>
                                  <td>&nbsp;</td>
                                <td align="right" class="NArialL"><bean:message key="label.sales.endUser"/>:</td>
                              <td class="NArialL">
                                <html:select name="ordersForm" property="endUser" styleClass="txfield">
                                  <html:option value="0">All <bean:message key="label.sales.endUser"/>s</html:option>
                                        <html:options collection="endUserList" property="value" labelProperty="label"/>
                                </html:select>
                                 </td>
                            </tr>
                            <tr>
                                <td class="NArialL">&nbsp;</td>
                                <td class="NArialL">&nbsp;</td>
                                <td class="NArialL">&nbsp;</td>
                                <td class="NArialL" align="right">Year:</td>
                                <td>
                                    <html:select name="ordersForm" property="year" styleClass="txfield">
                                        <html:option value="">--All--</html:option>
                                        <html:options collection="years" property="value" labelProperty="label" />
                                    </html:select>
                                </td>
                            </tr>
                            <tr><td colspan="5"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>

                            <tr>
                                <td colspan="5" align="center">
                                    <input type=image border="0" src="<%=chipTracContext%>/jsp/includes/images/search.gif" width="53" height="17" onmouseover="window.status='Click to Search for Sales Order List';return true" onmouseout="window.status='';return true" title="Click here to Search for Sales Order List"/>
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    <a href="javascript:reset();"onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset" ><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17"></a>
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr><td><img height=10 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td></tr>
                <tr>
                    <td>
                        <logic:equal name="showList" value="TRUE">
                        <table border="0" width="100%" align=left>
                            <tr>
                                <td align="center" bgcolor="#993333" nowrap><font class="NArialL"><font color="#FFFFFF">Sales Order #</font></font></td>
                                <td align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Customer Name</font></font></td>
                                <td align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><bean:message key="label.sales.endCustomer"/></font></font></td>
                                <td align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><bean:message key="label.sales.endUser"/></font></font></td>
                                <td align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Booking Date</font></font></td>
                                <td align="center" bgcolor="#993333" nowrap><font class="NArialL"><font color="#FFFFFF">Status / Hold</font></font></td>
                                <td align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Actions</font></font></td>
                            </tr>
                            <% int bgcount = 0;%>
                            <% ArrayList orderList = (ArrayList)request.getAttribute ( "pendingList" );%>
                            <logic:iterate id="Orders" name="pendingList">
                            <% Orders orders = (Orders)orderList.get(bgcount); %>
                            <% int salesOrderId = orders.getSalesOrderId (); %>
                            <% bgcount = bgcount + 1; %>
                            <tr>
                                <td align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>>
                                    <font class="NArialL"><bean:write name="Orders" property="salesOrderNo"  /></font>
                                </td>
                                <td align="left" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>>
                                    <font class="NArialL"><bean:write name="Orders" property="customerName" /></font>
                                </td>
                                <td align="left" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>>
                                    <font class="NArialL"><bean:write name="Orders" property="endCustomerName" /></font>
                                </td>
                                <td align="left" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>>
                                    <font class="NArialL"><bean:write name="Orders" property="endUserName" /></font>
                                </td>
                                <td align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>>
                                    <font class="NArialL"><bean:write name="Orders" property="bookingDate" /></font>
                                </td>
                                <td align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>>
                                    <font class="NArialL"><bean:write name="Orders" property="status" /></font>
                                </td>
                                <td align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>>
                                    <font class="NArialL">
                                    <% if( ( request.getParameter("isSample") != null ) && ( request.getParameter( "isSample" ).equals( "0" ) ) ) { %>
                                        <chiptrack:restrictedLink functionality='<%=Functionality.SAMPLE_PENDING_ORDER%>' action='<%=User.USER_ACTION_VIEW%>' styleClass="leftsection" href='<%=chipTracContext + "/approveOrder.do?salesOrderId=" + salesOrderId + "&isSample=" + isSample%>' onmouseover="window.status='Click to Approve this pending sales Order';return true" onmouseout="window.status='';return true">Approve</chiptrack:restrictedLink>
                                    <% } else { %>
                                        <chiptrack:restrictedLink functionality='<%=Functionality.SALES_PENDING_ORDER%>' action='<%=User.USER_ACTION_VIEW%>' styleClass="leftsection" href='<%=chipTracContext + "/approveOrder.do?salesOrderId=" + salesOrderId + "&isSample=" + isSample%>' onmouseover="window.status='Click to Approve this pending sales Order';return true" onmouseout="window.status='';return true">Approve</chiptrack:restrictedLink>
                                    <% } %>
                                    </font>
                                </td>
                            </tr>
                            </logic:iterate>
                        </table>
                        </logic:equal>
                    </td>
                </tr>
            </table>
            <input type="hidden" name="action" value="">
            <input type="hidden" name="isSample" value="<%=request.getParameter("isSample")%>">
            </html:form>
            <BR><BR><BR></TD>
        <TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
    </TR>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</BODY>
</HTML>